package com.itheima.controller;


import com.itheima.constant.MessageConstant;
import com.itheima.entity.BusinessReportBean;
import com.itheima.entity.Result;
import com.itheima.service.MemberService;
import com.itheima.service.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 报表
 */
@Api(tags = "ReportController-报表相关接口")
@RestController
@RequestMapping("/report")
public class ReportController {
    @Autowired
    private MemberService memberService;
    @Autowired
    private ReportService reportService;

    @ApiOperation(value = "会员统计", notes = "会员统计")
    @GetMapping("/getMemberReport")
    public Result getMemberReport() {
        // 获取年月时间列表
        List<String> months = reportService.getMonthsOfLastYear();
        // 获取会员总数
        List<Integer> members = reportService.getMembersOfLastYear();
        // 返回结果 months  memberCount
        Map<String, List> map = new HashMap<>();
        map.put("months", months);
        map.put("memberCount", members);
        if (months != null && members != null) {
            return new Result(true, MessageConstant.GET_MEMBER_NUMBER_REPORT_SUCCESS, map);
        }
        return new Result(false, MessageConstant.GET_MEMBER_NUMBER_REPORT_FAIL, null);
    }

    //查询套餐预约占比数据统计
    @ApiOperation(value = "查询套餐预约占比数据统计", notes = "查询套餐预约占比数据统计")
    @GetMapping("/getSetmealReport")
    public Result getSetmealReport() {

        //调用Service查询
        try {
            List<Object> setmealReport = reportService.getSetmealReport();
            if (setmealReport.get(0) != null && setmealReport.get(1) != null) {
                //结果处理后封装到map集合
                Map<String, Object> map = new HashMap();
                map.put("setmealNames", setmealReport.get(0));
                map.put("setmealCount", setmealReport.get(1));
//                 返回结果:setmealNames  setmealCount
                return new Result(true, MessageConstant.GET_SETMEAL_COUNT_REPORT_SUCCESS, map);
            } else {
                return new Result(false, MessageConstant.GET_SETMEAL_COUNT_REPORT_FAIL);
            }

        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_SETMEAL_COUNT_REPORT_FAIL);
        }


    }


    //获取运营数据统计
    @ApiOperation(value = "获取运营数据统计", notes = "获取运营数据统计")
    @GetMapping("/getBusinessReportData")
    public Result getBusinessReportData() {
        BusinessReportBean businessReportData = reportService.getBusinessReportData();
        if (businessReportData != null) {
            return new Result(true, MessageConstant.GET_BUSINESS_REPORT_SUCCESS, businessReportData);
        }
        return new Result(false, MessageConstant.GET_BUSINESS_REPORT_FAIL);
    }

    //运营数据报表导出
    @ApiOperation(value = "运营数据报表导出", notes = "运营数据报表导出")
    @GetMapping("/exportBusinessReport")
    public void exportBusinessReport(HttpServletRequest request, HttpServletResponse response) throws IOException, InvalidFormatException {
        //获取模板路径
//        File rootPath = new File(ResourceUtils.getURL("classpath:").getPath());
//
//        //SpringBoot项目获取根目录的方式
//        File templatePath = new File(rootPath.getAbsolutePath(), "static/template/report_template.xlsx");
//        File templatePath = ResourceUtils.getFile("classpath:static/template/report_template.xlsx");
        InputStream templatePath = this.getClass().getResourceAsStream("/static/template/report_template.xlsx");
        //        读取模板文件产生workbook对象,这个workbook是一个有内容的工作薄
//        Workbook workbook = new XSSFWorkbook(new FileInputStream(templatePath));
        Workbook workbook = new XSSFWorkbook(templatePath);
//        Workbook workbook = new XSSFWorkbook(templatePath);  jdk8使用
        //        读取工作薄的第一个工作表，向工作表中放数据
        Sheet sheet = workbook.getSheetAt(0);
        //查询报表数据
        BusinessReportBean businessReportData = reportService.getBusinessReportData();
        //第2行
        Row row2 = sheet.getRow(2);
        //设置日期
        Cell cell25 = row2.getCell(5);
        cell25.setCellValue(businessReportData.getReportDate());
        //第4行
        Row row4 = sheet.getRow(4);
        //新增会员数
        Cell cell45 = row4.getCell(5);
        cell45.setCellValue(businessReportData.getTodayNewMember());
        //新增会员数
        Cell cell47 = row4.getCell(7);
        cell47.setCellValue(businessReportData.getTotalMember());
        //第5行
        Row row5 = sheet.getRow(5);
        //本周新增会员数
        Cell cell55 = row5.getCell(5);
        cell55.setCellValue(businessReportData.getThisWeekNewMember());
        //本月新增会员数
        Cell cell57 = row5.getCell(7);
        cell57.setCellValue(businessReportData.getThisMonthNewMember());
        //第8行
        Row row7 = sheet.getRow(7);
        //今日预约数
        Cell cell75 = row7.getCell(5);
        cell75.setCellValue(businessReportData.getTodayOrderNumber());
        //今日到诊数
        Cell cell77 = row7.getCell(7);
        cell77.setCellValue(businessReportData.getTodayVisitsNumber());
        //第8行
        Row row8 = sheet.getRow(8);
        //本周预约数
        Cell cell85 = row8.getCell(5);
        cell85.setCellValue(businessReportData.getThisWeekOrderNumber());
        //本周到诊数
        Cell cell87 = row8.getCell(7);
        cell87.setCellValue(businessReportData.getThisWeekVisitsNumber());
        //第9行
        Row row9 = sheet.getRow(9);
        //本月预约数
        Cell cell95 = row9.getCell(5);
        cell95.setCellValue(businessReportData.getThisMonthOrderNumber());
        //本月到诊数
        Cell cell97 = row9.getCell(7);
        cell97.setCellValue(businessReportData.getThisMonthVisitsNumber());
        for (int i = 12; i <= businessReportData.getHotSetmeal().size() + 11; i++) {
            Row row = sheet.getRow(i);
            //套餐名称
            Cell cell4 = row.getCell(4);
            String name = (String) businessReportData.getHotSetmeal().get(i - 12).get("name");
            cell4.setCellValue(name);
            //预约数量
            Cell cell5 = row.getCell(5);
            Integer number = (Integer) businessReportData.getHotSetmeal().get(i - 12).get("setmeal_count");
            cell5.setCellValue(number);
            //占比
            Cell cell6 = row.getCell(6);
            Double proportion = (Double) businessReportData.getHotSetmeal().get(i - 12).get("proportion");

            cell6.setCellValue(proportion);
        }
//            导出的文件名称
        String filename = "report_template.xlsx";
        //            设置文件的打开方式和mime类型
        ServletOutputStream outputStream = response.getOutputStream();
        response.setHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes(), "ISO8859-1"));
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        workbook.write(outputStream);
    }

    /**
     * pdf下载
     * @param request
     * @param response
     * @return
     */
    @GetMapping("/exportBusinessReport4PDF")
    public Result exportBusinessReport4PDF(HttpServletRequest request, HttpServletResponse response) {
        try {
            //连接数据库
//            Class.forName("com.mysql.jdbc.Driver");
//            Connection connection =
//                    DriverManager.getConnection("jdbc:mysql://localhost:3306/health",
//                            "root",
//                            "123mysql");
            //获取模板路径
//            String rootPath = ResourceUtils.getURL("classpath:").getPath();
//            String jrxmlPath = rootPath + "static/template/health_business3.jrxml";
//            String jasperPath = rootPath + "static/template/health_business3.jasper";
            //编译模板
//            JasperCompileManager.compileReportToFile(jrxmlPath,jasperPath);
            //获取数据
            BusinessReportBean businessReportData = reportService.getBusinessReportData();

            //动态获取模板文件绝对磁盘路径
//            String jrxmlPath = request.getSession().getServletContext().getRealPath("template") + File.separator + "health_business3.jrxml";
//            String jasperPath = request.getSession().getServletContext().getRealPath("template") + File.separator + "health_business3.jasper";
            InputStream jrxmlPath = this.getClass().getResourceAsStream("/static/template/health_business3.jrxml");
            InputStream jasperPath = this.getClass().getResourceAsStream("/static/template/health_business3.jasper");
//            String jrxmlPath = this.getClass().getClassLoader().getResource("static/template/health_business3.jrxml").getPath();
//            String jasperPath = this.getClass().getClassLoader().getResource("static/template/health_business3.jasper").getPath();
            //编译模板  编译管理器
//            JasperCompileManager.compileReportToFile(jrxmlPath, jasperPath);
            //填充数据---使用JavaBean数据源方式填充
            HashMap mapDate = new HashMap();
            mapDate.put("reportDate",businessReportData.getReportDate());
            mapDate.put("todayNewMember",businessReportData.getTodayNewMember());
            mapDate.put("totalMember",businessReportData.getTotalMember());
            mapDate.put("thisWeekNewMember",businessReportData.getThisWeekNewMember());
            mapDate.put("thisMonthNewMember",businessReportData.getThisMonthNewMember());
            mapDate.put("todayOrderNumber",businessReportData.getTodayOrderNumber());
            mapDate.put("todayVisitsNumber",businessReportData.getTodayVisitsNumber());
            mapDate.put("thisWeekOrderNumber",businessReportData.getThisWeekOrderNumber());
            mapDate.put("thisWeekVisitsNumber",businessReportData.getThisWeekVisitsNumber());
            mapDate.put("thisMonthOrderNumber",businessReportData.getThisMonthOrderNumber());
            mapDate.put("thisMonthVisitsNumber",businessReportData.getThisMonthVisitsNumber());
            mapDate.put("logo","iVBORw0KGgoAAAANSUhEUgAAALwAAAA5CAYAAACMNEHAAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyFpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ4IDc5LjE2NDAzNiwgMjAxOS8wOC8xMy0wMTowNjo1NyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9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Y/ljaY9D0uLH3jCjCrORVpv2dEjS60Bu1MvXcdGkSYbkPZ4mRlN2UHsK5GhK4Y6qYL2cAXId0oA7yf2Crl+psx+/NTrpPJey6yznHJTSci7RT8+HM2u2067en/a7og37FaU1VC3GHuaxPPycZXS2OjCaNIAO2q0MH043Vi2APb+D6h3O7/sGGB/k9pU0HkH7OjW1nQxTS/ge5J3TzBpJbTWQGqydwzvQna8n27OdQqBbiLbkW8BHW1oKX0dH1qQdli9V7GHJskzafj6cKjtOG7wW3+cELGFhlc9i5GYGJepiQ9pONMCUz8hXTYZz3yHot9rlsbKw8FBhryQ6vbxeQ4LoA3Y6DFL11TOSaKf3Y3REL9OBHKS1quAXT/ZjvY+wPbgGq5BdrgrSd/XouzZlD5PyjXlde7b3CkNbgi6XY+cJn8xO9rzK7E8I7fWAL+kfFJ5iSBw9yWWaQ4dQlh1vltcfe7dP+ekMv+VxH5pE/5J4XfpKLTzaqn8eBosrPS33+pVSGf4PpuwhH/1mmk56qt1rxnYjnVW0sxqd6RconWH361V+AdCvVcEPl+nJJwhtLpDrEJ5twPaebphG0JZV+D4+phkHcy23qD5e9l4EdITKMNVrREk2ApM55AN2Y4x9Og9PpYmyRxVeLGkRQ4LlDad3CMH0g9xvo4NjrFeD0OvlP8ROtcKYH7qAdeqJNt9w31w6O2aYTnPY/jHS/qWUzIfyOjiNXxhRGmiVE2k7D2anQrQJi7Iup7a4ktpgH4YWhxv2+xhGghqzk26jxkDn+FBHvSD1qUHO4X2ggYZhVTTe5wE6y+ZEkUfpsK5M5fuVxp+eX6N+n1qwio7fiKKahxrR3k17zy9x+0v0COgR/eFNmpV0pCKgR5RxCm3SRBTR3kxRWDKiCPARRRQBPqKI/gD0PwEGAOkw2UijeqFLAAAAAElFTkSuQmCC");

            //填充hotSetmeal-使用JavaBean数据源方式填充
            List<HashMap<String, Object>> hotSetmeal = businessReportData.getHotSetmeal();
//            JasperPrint JasperPrint =
            //第二个参数：parameters传值，第二个参数：Fields传值

            JasperPrint jasperPrint = JasperFillManager.fillReport(jasperPath,mapDate,new JRBeanCollectionDataSource(hotSetmeal));

            //传输
            ServletOutputStream out = response.getOutputStream();
            response.setContentType("application/pdf");
            response.setHeader("content-Disposition", "attachment;filename=report.pdf");

            //输出文件
            JasperExportManager.exportReportToPdfStream(jasperPrint,out);

            return null;

        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_BUSINESS_REPORT_FAIL);
        }
    }
}
